package com.dawn.common.lang;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result implements Serializable {
    private int stats; //200 状态码//其他异常
    private String msg;
    private Object data;

    public static Result success(int stats,String msg,Object data){
        Result r = new Result(stats,msg,data);
        return r;
    }

    public static Result success(Object data){

        return success(200,"操作成功",data);
    }

//    数据异常封装
    public static Result fail(int stats,String msg,Object data){
        Result r = new Result(stats,msg,data);
        return r;
    }

    public static Result fail(String msg,Object data){
        return fail(400,msg,data);
    }

    public static Result fail(String msg){
        return fail(400,msg,null);
    }
}
